home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / QuickDraw / TickAnimateƒ / TickAnimate.p < prev    next >
Encoding:
Text File  |  1992-07-15  |  2.7 KB  |  101 lines  |  [TEXT/MPS ]

  1.  
  2. PROGRAM ReleaseTst;
  3.  
  4. USES    Quickdraw,MemTypes,SysEqu,ToolUtils,Resources,Dialogs,OSUtils,Retrace,Fonts,OSEvents,
  5.         Windows,menus;
  6.  
  7. CONST
  8.     iAnimate = 1;
  9.     iQuit = 2;
  10.     iUser1 = 3;
  11.     iUser2 = 4;
  12.     
  13. VAR
  14.     item : handle;
  15.     err,itemType,itemHit : integer;
  16.     MyDialog : DialogPtr;
  17.     theRect : rect;
  18.     animating,quit : boolean;
  19.     Counter : byte;
  20.     CurTicks : longint;
  21.     theEvent : EventRecord;
  22.  
  23. {------------------------------------------------------------------------------------}
  24.  
  25. PROCEDURE InitMac;
  26.  
  27. BEGIN                       {InitMac}
  28.  
  29.     {UnLoadSeg(@_DataInit);}               {remove data initialization code before any allocations}
  30.     InitGraf(@thePort);                {initialize QuickDraw}
  31.     InitFonts;                           {initialize Font Manager}
  32.     FlushEvents(everyEvent, 0);        {call OS Event Mgr to discard any previous events}
  33.     InitWindows;                       {initialize Window Manager}
  34.     InitMenus;                           {initialize Menu Manager}
  35.     TEInit;                            {initialize TextEdit}
  36.     InitDialogs(NIL);                   {initialize Dialog Manager}
  37.     InitCursor;                        {call QuickDraw to make cursor (pointer) an arrow}
  38.     quit := false;                        {always initialize them booleans!}
  39.     animating := false;
  40.     Counter := $21;
  41.  
  42. END;                       {InitMac}
  43.  
  44. {------------------------------------------------------------------------------------}
  45.  
  46. BEGIN                              {main PROGRAM}
  47.     
  48.     InitMac;
  49.     MyDialog := GetNewDialog (1,nil,pointer(-1));
  50.     if MyDialog <> nil then
  51.     begin
  52.         SetPort(MyDialog);
  53.         GetDItem (MyDialog,iUser1,itemType,item,theRect);
  54.         FrameRect (theRect);
  55.         TextFont (helvetica);
  56.         TextSize (14);
  57.         moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+15);
  58.         DrawString ('Welcome To TickAnimator');
  59.         GetDItem (MyDialog,iUser2,itemType,item,theRect);
  60.         FrameRect (theRect);
  61.         insetRect (theRect,3,3);
  62.         TextFont (helvetica);
  63.         TextSize (24);
  64.         moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
  65.         DrawString ('Cameron Birse - 1990');
  66.         SetFontLock (true);
  67.         err := noerr;
  68.         CurTicks := tickcount;
  69.         repeat
  70.             if WaitNextEvent (EveryEvent,theEvent,1,nil) then
  71.             if isDialogEvent (theEvent) then
  72.             if DialogSelect (theEvent,MyDialog,itemHit) then
  73.             case itemHit of
  74.                 iAnimate : if not animating then animating := true else
  75.                             if animating then 
  76.                             begin
  77.                                 eraseRect (theRect);
  78.                                 moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
  79.                                 DrawString ('Cameron Birse - 1990');
  80.                                 animating := false;
  81.                             end;
  82.                 iQuit : quit := true;
  83.             end; {case}
  84.             if CurTicks < (TickCount-8) then
  85.             begin
  86.                 CurTicks := TickCount;
  87.                 if animating then
  88.                 begin
  89.                     eraseRect (theRect);
  90.                     moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
  91.                     DrawChar (char(Counter));
  92.                     Counter := Counter + 1;
  93.                     if Counter > $AA then Counter := $21;
  94.                 end;
  95.             end;
  96.         until quit;
  97.         SetFontLock (false);
  98.         TextFont (systemFont);
  99.         TextSize (12);
  100.     end;
  101. END.